package Test02;

import java.util.ArrayList;

public class CoderTest01 {
    public static void main(String[] args) {
        ArrayList<Coder> list = new ArrayList<>();
        list.add(new Coder("王宝强", 25, "打篮球"));
        list.add(new Coder("汪峰", 35, "游泳"));
        list.add(new Coder("李铁", 19, "踢足球"));
        list.add(new Coder("姚明", 18, "击剑"));
        for (int i = list.size() - 1;i>= 0; i--) {
            Coder coder = list.get(i);
            int age = coder.getAge();
            String name = coder.getName();
            if (age >= 30) {
                list.set(i, new Coder(name,age,"打保龄球"));
            }
            if (age <= 20) {
                list.remove(i);
            } else {
                System.out.println(name + "----" +
                        age + "----" +
                        coder.getLike());
            }
        }
    }
}
